package l2hc.gameserver.instancemanager;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import l2hc.gameserver.model.Player;
import l2hc.gameserver.network.serverpackets.ExBR_RecentProductListPacket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author KilRoy
 * @for Trigger and re-back Product List (buy in Prime Shop)
 */
public class PrimeShopManager
{
	private static final Logger _log = LoggerFactory.getLogger(CoupleManager.class);
	
    private ConcurrentHashMap<Integer, List<ItemMallItem>> recentList;
    
	private static PrimeShopManager _instance;
	
    public static PrimeShopManager getInstance() 
    {
    	if (_instance == null)
    		_instance = new PrimeShopManager();
    	return _instance;
	}
    
    private PrimeShopManager() 
    {
    	_log.info("Initializing Prime Shop Manager(Item Moll)");
        recentList = new ConcurrentHashMap<Integer, List<ItemMallItem>>();
    }
	
    public class ItemMallItem {
        public ItemMallItemTemplate template = null;
        public int count;
        public int price;
        public int order;
        public int iSale = 0;
        public int iDayWeek;
        public int iCategory2;
        public int iStartSale;
        public int iEndSale;
        public int iStartHour;
        public int iStartMin;
        public int iEndHour;
        public int iEndMin;
        public int iStock;
        public int iMaxStock;

        public int iWeight;
        public boolean iDropable;

        public ItemMallItem(ItemMallItemTemplate t) {
            template = t;
        }

        public boolean limit() {
            return iStock >= iMaxStock;
        }

        public boolean isLimited() {
            return iMaxStock > 0;
        }
    }

    public class ItemMallItemTemplate {
        public int brId;
        public int itemId;
        public int category;
    }
    
	public void recentProductList(Player player)
	{
		player.sendPacket(new ExBR_RecentProductListPacket(player.getObjectId()));
	}
	
    public List<ItemMallItem> getRecentListByOID(int objId) 
    {
        return recentList.get(objId) == null ? new ArrayList<ItemMallItem>() : recentList.get(objId);
    }
}